package net.tankwar.event;

import javafx.scene.input.MouseButton;
import net.jumpengine.M;
import net.jumpengine.enume.GameState;
import net.jumpengine.inter.IInitReady;
import net.jumpengine.inter.IMouseEvent;
import net.jumpengine.ui.ImageButton;

public class EditMouseEvent implements IMouseEvent,IInitReady {
	private EditStateEvent event;
	private ImageButton btu,moveIn,select,tmp;
	
	@Override
	public void init() {
		event=(EditStateEvent) M.e().getStateEvent(GameState.edit);
	}
	
	@Override
	public void click(int x, int y, MouseButton button) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mousePressed(int x, int y, MouseButton button) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseReleased(int x, int y, MouseButton button) {
		if(x<144) {
			if(button==MouseButton.PRIMARY) {
				select=M.b().FindBaseByPoint(x, y, ImageButton.class);
				
				event.setSelect(select);
			}
		}

	}

	@Override
	public void mouseMove(int x, int y, MouseButton button) {
		if(x<144) {
			btu=M.b().FindBaseByPoint(x, y, ImageButton.class);
			
			if(moveIn!=btu || moveIn==null) {
				moveIn=btu;
				event.setMoveIn(btu);
			}
		}else {
			event.setMoveIn(null);
		}

	}


}
